// ChimaeraSVN

// Copyright (C) 2008-2009 - ChimaeraSVN

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#pragma once

#pragma warning(push)
#include "svn_client.h"
#include "svn_pools.h"
#include "svn_config.h"
#pragma warning(pop)

#include "SVNPrompt.h"


class SVN
{
public:
	SVN(void);
	~SVN(void);
	
	
	BOOL List(const char *path_or_url, svn_boolean_t recurse);

	BOOL getuserinfo(const char *path_or_url, svn_boolean_t recurse);
	BOOL SVN::get_new_message(chimaeramessage_t **message,
							apr_int32_t *num,
							const char *path_or_url);

	/* @1 the path copied from, 
	 * @2 the destinate path in working copy
	 * @3 maybe will be used later
	 */
	BOOL import_file(const char *source_path, char *des_path, svn_boolean_t );
	BOOL update(const char *URL,const char *path, apr_int32_t sign,
		svn_boolean_t);

	/*
	 @2 if true, delete the file even if it has been edited
	 */
	BOOL remove(const char *path, svn_boolean_t force);

	BOOL CreateProject(const char *path_or_url,char *project_name,
							char *groupleader, char ** time_nodes_str,
							apr_byte_t node_num, char *projinfo,
							svn_boolean_t recurse);
	BOOL getuserlist(chimaerauserlist_t **user_list,
							apr_int32_t *num,apr_int32_t sign,
							const char *para,const char *path_or_url);
	BOOL editcolumns(apr_int32_t sign, svn_string_t *key,
		svn_string_t *value1, svn_string_t *value2,
		svn_string_t *value3, const char *path_or_url);
	BOOL getcolumns(apr_int32_t *group_recno,
		apr_int32_t sign, svn_string_t *key,
		svn_string_t *value1, const char *path_or_url);

	BOOL save(const char *path, svn_boolean_t force);
	BOOL lock(const char *path, svn_boolean_t steal_lock);
	BOOL unlock(const char *path, svn_boolean_t break_lock);

	BOOL get_latest_revnum(svn_revnum_t *latest_revnum,
		const char *path);
	BOOL Checkout(const char *URL, const char *path, 
		apr_int32_t sign,svn_boolean_t recurse);
	BOOL RemoveProject(const char *url, svn_boolean_t);

	//user edit interface
	BOOL InsertUser(char *username, apr_int32_t character, 
		char *certificate,  char *userinfo,
		const char *url);

	BOOL RemoveUser(svn_revnum_t user_recno, const char *url);

	BOOL EditUser(svn_revnum_t user_recno, char *username,
		apr_int32_t character, char *certificate,  
		char *userinfo, char * url);


	

	svn_error_t *				Err;			///< Global error object struct
	svn_client_ctx_t * 			m_pctx;			///< pointer to client context

	apr_hash_t *				dirents;
	
	SVNPrompt					m_prompt;
	apr_pool_t *				parentpool;		///< the main memory pool
	apr_pool_t *				pool;			///< 'root' memory pool
	svn_opt_revision_t			rev;			///< subversion revision. used by getRevision()


	//global variaties
	static svn_string_t *		user_ID;
	static svn_revnum_t				recno;

	static char * privilege;
	static char * user_name;

	//get user_ID from the usb_key  
	//maybe should create a user class, anyway
	//just try here first.
	static svn_string_t * get_userID(char *);
protected:	
	

private:

};

